<!DOCTYPE html>
<html lang="en">
<head>
    <script src="/static/js/dev.js"></script>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--bootstrap插件-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link href="/static/plugin/bootstrap/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/static/plugin/jo/joUI.css" rel="stylesheet"/>
    <!--字体插件-->
    <link href="/static/plugin/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="/static/plugin/layui-2.4.3/css/layui.css" rel="stylesheet"/>
    <!--ztree-->
    <link href="/static/plugin/zTree/css/metroStyle/metroStyle.css" rel="stylesheet"/>
    <!--common-->
    <link href="/static/css/common.css" rel="stylesheet"/>
    <title>统一配置信息视图</title>
</head>
<body class="skin-default">

<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12">
            <!--视图块-->
            <div class="container-fluid card">
                <div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <!--检索栏-->
                        <form class="form-inline search-bar" id="pageForm">
                            <div class="form-group">
                                <label class="control-label">配置Key：&nbsp;</label>
                                <input type="text" name="configKey" class="form-control">
                            </div>
                            <div class="form-group">
                                <label class="control-label">分组：&nbsp;</label>
                                <select name="configGroup" class="form-control">
                                    <option value=""></option>
                                    <option value="default">默认分组</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label class="control-label">配置类型：&nbsp;</label>
                                <select name="configType" class="form-control">
                                    <option value=""></option>
                                    <option value="1">普通KV</option>
                                    <option value="2">对象</option>
                                    <option value="3">集合</option>
                                    <option value="4">树</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label class="control-label">优先级：&nbsp;</label>
                                <select name="priority" class="form-control">
                                    <option value=""></option>
                                    <option value="1">高优先级</option>
                                    <option value="2">低优先级</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label class="control-label">状态：&nbsp;</label>
                                <select name="state" class="form-control">
                                    <option value=""></option>
                                    <option value="1">启用</option>
                                    <option value="2">禁用</option>
                                </select>
                            </div>
                            <button type="button" class="btn btn-primary" onclick="joView.select()"> <i class="fa fa-search" aria-hidden="true"></i>&nbsp;查询</button>
                        </form>
                        <!--/检索栏-->
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <!--按钮栏-->
                        <div class="form-group button-bar">
                            <button isShow="" type="button" class="btn btn-primary" onclick="joView.add()">
                                <i class="fa fa-plus" aria-hidden="true"></i>&nbsp;新增
                            </button>
                            <button type="button" class="btn btn-danger" onclick="joView.del()">
                                <i class="fa fa-trash-o" aria-hidden="true"></i>&nbsp;删除
                            </button>
                            <button type="button" class="btn btn-warning" onclick="window.location.reload()">
                                <i class="fa fa-refresh" aria-hidden="true"></i>&nbsp;刷新
                            </button>
                            <button type="button" class="btn btn-info" onclick="refreshAppConfig()">
                                <i class="fa fa-refresh" aria-hidden="true"></i>&nbsp;重新加载应用配置
                            </button>
                        </div>
                        <!--/按钮栏-->
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                        <div class="table-bar">
                            <!--grid-->
                            <div class="table-responsive">
                                <table class="table table-bordered table-hover table-line-auto" id="mainList" dataUrl="/config/configKv/getPage" deleteUrl="/config/configKv/delete" formUrl="/page/config/configKvForm.html">
                                    <!--<col field="id" title="自增主键" width="15%" align="" event="click" />-->
                                    <col field="configKey" title="配置KEY" width="20%" align=""  event="click"  />
                                    <col field="configValue" title="配置内容" width="30%" align=""  />
                                    <col field="remark" title="说明" width="20%" align=""  />
<!--                                    <col field="configGroup" title="分组" width="15%" align=""  />-->
                                    <col field="priorityShow" title="优先级" width="10%" align=""  />
                                    <!--<col field="configTypeShow" title="配置类型" width="10%" align=""  />-->
                                    <!--<col field="[=jo.formatTime('{updateTime}')]" title="修改时间" width="15%" align=""  order="updateTime"/>-->
                                    <col field="stateShow" title="状态" width="10%" align=""  />
                                    <col field="num" title="显示顺序" width="10%" align=""  order="num"/>
                                </table>
                            </div>
                            <!--/grid-->

                            <!--分页条-->
                            <div class="page-bar" gridId="mainList">

                            </div>
                            <!--/分页条-->
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>

<!--配置信息-->
<script src="/static/js/config.js"></script>
<!--jquery-->
<script src="/static/plugin/jquery/jquery-3.3.1.js"></script>
<script src="/static/plugin/jquery/jquery.cookie.js"></script>
<!--bootstrap-->
<script src="/static/plugin/bootstrap/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<!--[if lt IE 9]>
<script src="/static/plugin/other/html5shiv.js"></script>
<script src="/static/plugin/other/respond.min.js"></script>
<![endif]-->
<!--layui-->
<script src="/static/plugin/layui-2.4.3/layui.all.js"></script>
<!--ztree-->
<script src="/static/plugin/zTree/js/jquery.ztree.all.js"></script>
<!--common-->
<script src="/static/js/common.js"></script>
<!--jo-->
<script src="/static/plugin/jo/jo.js"></script>
<script src="/static/plugin/jo/jo-adapt.js"></script>
<script src="/static/plugin/jo/jo-page-view.js"></script>
<script src="/static/plugin/jo/jo-page-form.js"></script>
<script src="/static/plugin/jo/jo-listener.js"></script>
<script type="text/javascript">
    var stateConfig = {1: htmlWrap4Label('启用', 'label-primary'), 2: htmlWrap4Label('禁用', 'label-danger')};//状态枚举
    var typeConfig = {1: '普通KV', 2: '对象', 3: '集合', 4: '树'};//类型枚举
    var priorityConfig = {1: htmlWrap4Label('高', 'label-primary'), 2: htmlWrap4Label('低', 'label-warning')};//类型枚举
    $(function(){
        joView.init({grid:$("#mainList"),PKName:"id"});//初始化页面
    });
    //表格渲染时行处理,参数1为当前行的数据对象,参数2为当前行的索引值(最小为0)
    joView.handleItem = function(oItem,iIndex){
        oItem.stateShow = jo.getDefVal(stateConfig[oItem.state], oItem.state);
        oItem.configTypeShow = jo.getDefVal(typeConfig[oItem.configType], oItem.configType);
        oItem.priorityShow = jo.getDefVal(priorityConfig[oItem.priority], oItem.priority);
    };
    //表格渲染完成后的回调,参数为表格数据(数组对象)
    joView.setGridDataAfter = function(oList){

    };
    /* 关于joView更多回调函数和配置参数可查看jo-page-view.js */

    //刷新配置
    function refreshAppConfig(){
        jo.confirm('您确定要重新加载配置文件吗?', function(){
            jo.postAjax('/config/client/refreshEnvironment', {}, function(json){
                jo.showTipsMsg(json.info);
            }, true);
        });
    }
</script>
</body>
</html>
